/*     */ package com.zimbra.cs.index;
/*     */ 
/*     */ import com.google.common.annotations.VisibleForTesting;
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.extension.ExtensionUtil;
/*     */ import com.zimbra.cs.mailbox.MailItem;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.util.Zimbra;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class IndexStore
/*     */ {
/*     */   private static Factory factory;
/*     */   
/*     */   public abstract Indexer openIndexer()
/*     */     throws IOException;
/*     */   
/*     */   public abstract ZimbraIndexSearcher openSearcher()
/*     */     throws IOException;
/*     */   
/*     */   public abstract void warmup();
/*     */   
/*     */   public abstract void evict();
/*     */   
/*     */   public abstract void deleteIndex()
/*     */     throws IOException;
/*     */   
/*     */   public abstract boolean isPendingDelete();
/*     */   
/*     */   public abstract void setPendingDelete(boolean paramBoolean);
/*     */   
/*     */   public abstract void optimize();
/*     */   
/*     */   public abstract boolean verify(PrintStream paramPrintStream)
/*     */     throws IOException;
/*     */   
/*     */   public static Factory getFactory()
/*     */   {
/*  87 */     if (factory == null) {
/*  88 */       setFactory(LC.zimbra_class_index_store_factory.value());
/*     */     }
/*  90 */     return factory;
/*     */   }
/*     */   
/*     */   public static void setFields(MailItem item, IndexDocument doc) {
/*  94 */     doc.removeSortSubject();
/*  95 */     doc.addSortSubject(item.getSortSubject());
/*  96 */     doc.removeSortName();
/*  97 */     doc.addSortName(item.getSortSender());
/*  98 */     doc.removeMailboxBlobId();
/*  99 */     doc.addMailboxBlobId(item.getId());
/*     */     
/*     */ 
/* 102 */     doc.removeSortDate();
/* 103 */     doc.addSortDate(item.getDate());
/* 104 */     doc.removeSortSize();
/* 105 */     doc.addSortSize(item.getSize());
/* 106 */     doc.removeSortAttachment();
/* 107 */     doc.addSortAttachment(item.hasAttachment());
/* 108 */     doc.removeSortFlag();
/* 109 */     doc.addSortFlag(item.isFlagged());
/* 110 */     doc.removeSortPriority();
/* 111 */     doc.addSortPriority(item.getFlagBitmask());
/*     */   }
/*     */   
/*     */   @VisibleForTesting
/*     */   public static final void setFactory(String factoryClassName) {
/* 116 */     Class<? extends Factory> factoryClass = null;
/*     */     try {
/*     */       try {
/* 119 */         factoryClass = Class.forName(factoryClassName).asSubclass(Factory.class);
/*     */       } catch (ClassNotFoundException e) {
/*     */         try {
/* 122 */           factoryClass = ExtensionUtil.findClass(factoryClassName).asSubclass(Factory.class);
/*     */         }
/*     */         catch (ClassNotFoundException cnfe) {
/* 125 */           Zimbra.halt("Unable to initialize Index Store for class " + factoryClassName, cnfe);
/*     */         }
/*     */       }
/*     */     } catch (ClassCastException cce) {
/* 129 */       Zimbra.halt("Unable to initialize Index Store for class " + factoryClassName, cce);
/*     */     }
/* 131 */     setFactory(factoryClass);
/* 132 */     ZimbraLog.index.info("Using Index Store %s", new Object[] { factory.getClass().getDeclaringClass().getSimpleName() });
/*     */   }
/*     */   
/*     */   private static final synchronized void setFactory(Class<? extends Factory> factoryClass) {
/*     */     try {
/* 137 */       factory = (Factory)factoryClass.newInstance();
/*     */     } catch (InstantiationException ie) {
/* 139 */       Zimbra.halt("Unable to initialize Index Store for " + factoryClass.getDeclaringClass().getSimpleName(), ie);
/*     */     } catch (IllegalAccessException iae) {
/* 141 */       Zimbra.halt("Unable to initialize Index Store for " + factoryClass.getDeclaringClass().getSimpleName(), iae);
/*     */     }
/*     */   }
/*     */   
/*     */   public static abstract interface Factory
/*     */   {
/*     */     public abstract IndexStore getIndexStore(Mailbox paramMailbox)
/*     */       throws ServiceException;
/*     */     
/*     */     public abstract void destroy();
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/index/IndexStore.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */